<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.7/iconfont.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>地区列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> <a href="index.html">首页</a> 
<a href="javascript:;" class="areareload" id="deep0" data-id="0" data-deep="0"><span class="c-gray en">&gt;</span> 全国列表</a>
<a href="javascript:;" class="areareload" style="display:none" id="deep1" data-id="" data-deep="1"><i class="c-gray en">&gt;</i> <span></span></a>
<a href="javascript:;" class="areareload" style="display:none" id="deep2" data-id="" data-deep="2"><i class="c-gray en">&gt;</i> <span></span></a>
<a href="javascript:;" class="areareload" style="display:none" id="deep3" data-id="" data-deep="3"><i class="c-gray en">&gt;</i> <span></span></a>
<a href="javascript:;" class="areareload" style="display:none" id="deep4" data-id="" data-deep="4"><i class="c-gray en">&gt;</i> <span></span></a>

<a class="btn btn-success radius r mr-20 reload" style="line-height:1.6em;margin-top:3px" href="javascript:;" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="pd-10">
	
	<div class="mt-20">
		<table class="table table-border table-bordered table-bg table-hover table-sort" id="categorylist">
			<thead>
				<tr class="text-c sort0">
					<th width="40" class="valueid"><input name="" type="checkbox" value=""></th>
					<th width="20" class="fun-sort" data-name="area_id" data-flag="0">ID</th>
					<th width="20" class="fun-sort" data-name="area_title" data-flag="0">首字母</th>
					<th width="150">省名称</th>
					<th width="60">所属区域</th>
					<th width="60" class="fun-sort" data-name="area_sort" data-flag="0">排序</th>
					<th width="60">显示状态</th>
					<th width="120">操作</th>
				</tr>
			</thead>
			<tbody id="content_sp">
				
			</tbody>
		</table>
	</div>

	<div class="cl pd-5 bg-1 bk-gray mt-10"> 
		<a href="pinyin();" class="btn btn-warning l mr-10 mt-5 radius "><i class="Hui-iconfont">&#xe6de;</i> 批量拼音</a> 
		<a href="javascript:;" class="btn btn-warning l mr-10 mt-5 radius fun-all" data-type="stop"><i class="Hui-iconfont">&#xe6de;</i> 批量关闭</a> 
		<a href="javascript:;" class="btn btn-success l mr-10 mt-5 radius fun-all" data-type="start"><i class="Hui-iconfont">&#xe603;</i> 批量开启</a> 
		<a href="javascript:;" class="btn btn-danger l mr-10 mt-5 radius fun-all" data-type="del"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> 
		<a class="btn btn-primary radius mt-5 l mr-10" data-title="添加内容" href="javascript:;" onclick="_open('添加','area-add.html','50%','50%',false)" href="javascript:;">
			<i class="Hui-iconfont">&#xe600;</i> 添加省份
		</a>
		<span class="r pt-5"  style="line-height: 35px;" id="page"></span>
		<span class="r mr-10"  style="line-height: 40px;" id="dataall"></span>
		
	</div>


</div>
<!-- 模版 -->
<script id="test" type="text/html">
<% for (x in list) { %>
	<tr class="text-c va-m sort1" >
		<td class="valueid"><input name="" type="checkbox" value="<%=list[x].area_id%>"></td>
		<td class="text-l"><%=list[x].area_id%></td>
		<td class="text-l"><%=list[x].area_title%></td>
		<td class="text-l">
		<% if(list[x].sum>0){ %>
			<a style="text-decoration:none; " href="javascript:;"  class="arealist-openclose" data-deep="<%=list[x].area_deep%>" data-areaname="<%=list[x].area_name%>" data-id="<%=list[x].area_id%>">
			<b><span style="width: 18px; font-size: 16px; display: inline-block;">+</span><%=list[x].area_name%>(<%=list[x].sum%>)</b> </a>
		<% }else{ %>
			<b style="padding-left:37px"><%=list[x].area_name%></b>
		<% } %>
		</td>
		<td class="text-l "><%=list[x].area_region%></td>
		<td>
			<input type="text" size="3" class="paixu fun-paixu" name="area_sort" value="<%=list[x].area_sort%>" style="text-align: center;">
		</td>
		<td class="td-status">
			<input type="checkbox" class="switch fun-start-stop" style="outline: none;" <%if(list[x].area_status==1){ %>checked<% } %>/>
		</td>
		<td class="td-manage f-18">
		<a style="text-decoration:none" onClick="_open('添加<b class=c-primary><%=list[x].area_name%></b>下级地区','area-add.html?name=<%=list[x].area_name%>&parentid=<%=list[x].area_parent_id%>&deep=<%=list[x].area_deep%>&id=<%=list[x].area_id%>','50%','50%',true)" href="javascript:;" title="添加地区"><i class="Hui-iconfont">&#xe600;</i></a> 
		<a style="text-decoration:none" onClick="_open('分类编辑','area-add.html?editid=<%=list[x].area_id%>&parentid=<%=list[x].area_parent_id%>','50%','50%',true)" class="ml-5 edit" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a> 

		
		<a style="text-decoration:none" class="ml-5 fun-del" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>
		</td>
	</tr>
<%}%>
</script>


	


<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="js/H-ui.js"></script>
<script type="text/javascript" src="lib/layer/2.1/layer.js"></script>

<script type="text/javascript" src="lib/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="js/H-ui.admin.js"></script> 
<script src="/Public/js/template-native.js"></script> 
<script type="text/javascript" src="js/s.js"></script>
<script type="text/javascript" src="lib/laypage/laypage.js"></script> 
<script src="/Manage/js/lazyload.min.js"></script>
<script type="text/javascript" src="js/pinyin.js"></script>
<script type="text/javascript">
var API=API_AREA;
var kk=API;
var orderby='';
var search='';

loaddata(API,1);




function getpinyin(url){
	$.getJSON(url, function(data){
		for(x in data.datas){
			var area_id=data.datas[x].area_id;
			var area_name=data.datas[x].area_name;
			var area_title=copy(area_name);
			var area_t=area_title.substr(0, 1);
	    	area_t=area_t.toUpperCase();
	    	var posturl=API_AREA+"?id="+area_id;
			console.log(area_title);
			if(data.datas[x].area_title==""){
				$.post(posturl,
		            {
		              area_title  : area_title,
		              area_t    : area_t,
		            },
		            function(data){
		               
		    	})
			}
			var url2=API_AREA+"?pid="+area_id;
			if(data.datas[x].sum>0){
				getpinyin(url2);
			}
			
			
		}
	})

}

$(document).ready(function(){
// 00000000000000

	// getpinyin(API_AREA);

// 000000000000000
	$(document).on('click','a.areareload',function(){
		var id=$(this).data("id");
		var deep=$(this).data("deep");
		if(id==0){
			var url=API;
		}else{
			var url=API+"?pid="+id;
		}
		
		loaddata(url);
		for(var i=1; i<5; i++){
			if(i>deep){
				$("#deep"+i).hide();
			}
		}
	})

	// a.arealist-openclose显示隐藏子分类
	$(document).on('click','a.arealist-openclose',function(){

	    var deep=$(this).data("deep");
	    var areaname=$(this).data("areaname");
	    
	    var id=$(this).data("id");

	    var url=API+'?pid='+id;

	    loaddata(url);
	
	    if(deep==1){
	    	$("#deep1").show();
	    	$("#deep1").attr("data-id",id);
	    	
	    	$("#deep1 span").html(areaname);
	    }else if(deep==2){
	    	$("#deep2").show();
	    	$("#deep2").attr("data-id",id);
	   
	    	$("#deep2 span").html(areaname);
	    }else if(deep==3){
	    	$("#deep3").show();
	    	$("#deep3").attr("data-id",id);
	
	    	$("#deep3 span").html(areaname);
	    }else if(deep==4){
	    	$("#deep4").show();
	    	$("#deep4").attr("data-id",id);
	   
	    	$("#deep4 span").html(areaname);
	    }

	    
	})
})



</script>

</body>
</html>